<?php

namespace app\admin\service;

use app\admin\model\BoxDataOverview;

class BoxOverviewService extends BaseService
{

    public function getList()
    {
        $param = request()->param();

        $map = [];
        //默认时间为前一日
//        $time = date("Y-m-d ", strtotime("-1 day"));
//        $time = date("Y-m-d ");

        if(!empty($param['time_range'])){
            $map[] = ['date','>=',$param['time_range'][0]];
            $map[] = ['date','<=',$param['time_range'][1]];
        }
        $bannerIds = (new BoxDataOverview())
            ->where($map)
            ->order('date','desc')
            ->page(PAGE, PERPAGE)
            ->select();

        //获取数据总数
        $count = (new BoxDataOverview())->where($map)->count();

        //返回结果
        return  [
            "msg" => '操作成功',
            "code" => 0,
            "data" => $bannerIds,
            "count" => $count,
        ];
    }

}